﻿@using Tools
@{
    ViewBag.Title = "航次报告";
    ReportAnalysisModel data = (ReportAnalysisModel)ViewData["Data"];
}


<div id="content" class="content">
    <!-- begin breadcrumb -->
    <ol class="breadcrumb hidden-print pull-right">
        <li><a href="javascript:;">航次列表</a></li>
        <li class="active">信息统计</li>
    </ol>
    <!-- end breadcrumb -->
    <!-- begin page-header -->
    <h1 class="page-header hidden-print">
        @data.ShipName
        @*<small>@data.UpdateTime</small>*@
    </h1>
    <!-- end page-header -->
    <!-- begin invoice -->
    <div class="invoice">
        <div class="invoice-company">
            <span class="pull-right hidden-print">
                <a href="javascript:;" onclick="window.print()" class="btn btn-sm btn-success m-b-10"><i class="fa fa-print m-r-5"></i> Print</a>
            </span>
            航次总结-@data.VoyageNo
        </div>
        <div class="invoice-header">
            <div class="invoice-from">
                <small>出发港</small>
                <address class="m-t-5 m-b-5">
                    <strong>@data.Departure.DeparturePort</strong><br />
                    离港时间：@data.Departure.DepartureTime &nbsp;&nbsp;时区:@data.Departure.DepartureTimeZone<br />
                    离港吃水：@data.Departure.F.Replace("_", " ") / @data.Departure.A.Replace("_", " ")<br />
                    装货量: @data.Departure.LoadedCargo.Replace("_", " ")<br />
                    卸货量: @data.Departure.DischargedCargo.Replace("_", " ")
                </address>
            </div>
            @if(data.Arrival!=null)
            { 
            <div class="invoice-to">
                <small>目的港</small>
                <address class="m-t-5 m-b-5">
                    
                    <strong>@data.Arrival.ArrivalPort</strong><br/>
                    到达时间：@data.Arrival.ArrivalTime &nbsp;&nbsp;时区:@data.Arrival.ArrivalTimeZone<br/>
                    到港吃水：@data.Arrival.F.Replace("_", " ")/ @data.Arrival.A.Replace("_", " ")<br/>
                    装货量: @double.Parse(data.Arrival.LoadedCargo).ToString("f3") MT<br/>
                    卸货量: @double.Parse(data.Arrival.DischargedCargo).ToString("f3") MT
                </address>
            </div>
                <div class="invoice-date">
                    <div class="date m-t-5">航次用时：@(new TimeSpan(0, 0, int.Parse(data.SailTime)).TotalHours.ToString("f2")) 小时</div>
                    <div class="date m-t-5">航行距离：@data.Arrival.Distance.Replace("_", " ") </div>
                    <div class="date m-t-5">平均速度：@data.Arrival.AverageSpeed.Replace("_", " ") </div>
                </div>
            }
        </div>
        <div class="invoice-company">
            油耗信息
        </div>
        <div class="invoice-content">
            <div id="DailyRob" style="width: 100%; height: 400px;">

            </div>
        </div>
        <div class="invoice-content">
            <div class="table-responsive">
                <table class="table table-invoice">
                    <thead>
                        <tr>
                            <th></th>
                            <th>重油(MT)</th>
                            <th>轻油(MT)</th>
                            <th>汽缸油(L)</th>
                            <th>主机油(L)</th>
                            <th>辅机油(L)</th>
                            <th>淡水(MT)</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>
                                航次开始存量
                            </td>
                            <td>@data.Departure.StoredRob.FO</td>
                            <td>@data.Departure.StoredRob.DO</td>
                            <td>@data.Departure.StoredRob.MEcyl</td>
                            <td>@data.Departure.StoredRob.MEsys</td>
                            <td>@data.Departure.StoredRob.AEsys</td>
                            <td>@data.Departure.StoredRob.FW</td>
                        </tr>
                    <tr>
                        <td>
                            加油量
                        </td>
                        <td>@data.Departure.ReceivedRob.FO</td>
                        <td>@data.Departure.ReceivedRob.DO</td>
                        <td>@data.Departure.ReceivedRob.MEcyl</td>
                        <td>@data.Departure.ReceivedRob.MEsys</td>
                        <td>@data.Departure.ReceivedRob.AEsys</td>
                        <td>@data.Departure.ReceivedRob.FW</td>
                    </tr>
                        @if(data.Arrival!=null)
                        { 
                        <tr>
                            <td>
                                航次结束存量
                            </td>
                            <td>@data.Arrival.StoredRob.FO</td>
                            <td>@data.Arrival.StoredRob.DO</td>
                            <td>@data.Arrival.StoredRob.MEcyl</td>
                            <td>@data.Arrival.StoredRob.MEsys</td>
                            <td>@data.Arrival.StoredRob.AEsys</td>
                            <td>@data.Arrival.StoredRob.FW</td>
                        </tr>
                            <tr>
                                <td>
                                    消耗量
                                </td>
                                <td>@data.OilConsumption.FO</td>
                                <td>@data.OilConsumption.DO</td>
                                <td>@data.OilConsumption.MEcyl</td>
                                <td>@data.OilConsumption.MEsys</td>
                                <td>@data.OilConsumption.AEsys</td>
                                <td>@data.OilConsumption.FW</td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            <!--<div class="invoice-price">
                <div class="invoice-price-left">
                    <div class="invoice-price-row">
                        <div class="sub-price">
                            <small>SUBTOTAL</small>
                            4,500.00
                        </div>
                        <div class="sub-price">
                            <i class="fa fa-plus"></i>
                        </div>
                        <div class="sub-price">
                            <small>PAYPAL FEE (5.4%)</small>
                            108.00
                        </div>
                    </div>
                </div>
                <div class="invoice-price-right">
                    <small>TOTAL</small> 4508.00
                </div>
            </div>-->
        </div>
        <!--<div class="invoice-note">
            * Make all cheques payable to [Your Company Name]<br />
            * Payment is due within 30 days<br />
            * If you have any questions concerning this invoice, contact  [Name, Phone Number, Email]
        </div>-->
        
    </div>
    <!-- end invoice -->
</div>


@{
    String[] xdata= {};
    if(data.DailyRob!=null&&data.DailyRob.Count>0)
    {
        //用于图表数据
        xdata = data.DailyRob.Select(m => DateTime.Parse(m.Date).ToString("yyyy-MM-dd")).ToArray();
    }
    var length = data.DailyRob==null?0: data.DailyRob.Count;
    float[] FO=new float[length];
    float[] DO = new float[length];
    float[] MEsys = new float[length];
    float[] MEcyl = new float[length];
    float[] AEsys = new float[length];
    float[] FW = new float[length];
    for (int i = 0; i < length; i++)
    {
        var rob = data.DailyRob[i].Rob;
        FO[i] = rob.FO;
        DO[i] = rob.DO;
        MEsys[i] = rob.MEsys;
        MEcyl[i] = rob.MEcyl;
        AEsys[i] = rob.AEsys;
        FW[i] = rob.FW;
    }

}

@section footer {
    <script src="/Scripts/echarts.js"></script>
    <script>
        $(document)
            .ready(function() {
                App.init();
                var dailyRob = echarts.init(document.getElementById('DailyRob'));
                // 指定图表的配置项和数据
                option = {
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: ['重油', '轻油', '汽缸油', '主机油', '辅机油', '淡水'],
                        left: 'center'
                    },
                    grid: {
                        left: '5%',
                        right: '5%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: {
                        width: '100%',
                        boundaryGap: false,
                        data: @Html.Raw(JsonHelper.SerializeObject(xdata)),
                        name: '时间'
                    },
                    yAxis:
                    {
                        type: 'value',
                        name: '存油量',
                        
                    },
                    series: [
                        {
                            name: '重油',
                            type: 'line',
                            data: @Html.Raw(JsonHelper.SerializeObject(FO)),
                        },
                        {
                            name: '轻油',
                            type: 'line',
                            data: @Html.Raw(JsonHelper.SerializeObject(DO)),
                        },
                        {
                            name: '汽缸油',
                            type: 'line',
                            data: @Html.Raw(JsonHelper.SerializeObject(MEcyl)),
                        },
                        {
                            name: '主机油',
                            type: 'line',
                            data: @Html.Raw(JsonHelper.SerializeObject(MEsys)),
                        },
                        {
                            name: '辅机油',
                            type: 'line',
                            data: @Html.Raw(JsonHelper.SerializeObject(AEsys)),
                        },
                        {
                            name: '淡水',
                            type: 'line',
                            data: @Html.Raw(JsonHelper.SerializeObject(FW)),
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                dailyRob.setOption(option);
            });
    </script>
}
